import type { VxeTableGridOptions } from '@vben/plugins/vxe-table';

import type { OnActionClickFn } from '#/adapter/vxe-table';

export interface LedgerRecycleItem {
  accountant: string;
  actionAccountant: string;
  deleteTime: string;
  id: string;
  ledgerName: string;
  remark?: string;
  supervisor: string;
}

/**
 * 获取表格列配置
 */
export function useColumns(
  onActionClick?: OnActionClickFn<LedgerRecycleItem>,
): VxeTableGridOptions<LedgerRecycleItem>['columns'] {
  return [
    {
      align: 'left',
      field: 'ledgerName',
      title: '账簿名称',
      width: 200,
    },
    {
      align: 'center',
      field: 'accountant',
      title: '记账会计',
      width: 120,
    },
    {
      align: 'center',
      field: 'supervisor',
      title: '主管会计',
      width: 120,
    },
    {
      align: 'center',
      field: 'actionAccountant',
      title: '动账会计',
      width: 120,
    },
    {
      align: 'right',
      cellRender: {
        attrs: {
          nameField: 'ledgerName',
          nameTitle: '账簿名称',
          onClick: onActionClick,
        },
        name: 'CellOperation',
        options: [
          {
            code: 'restore',
            text: '恢复',
            type: 'primary',
          },
          {
            code: 'delete',
            text: '彻底删除',
            type: 'danger',
          },
        ],
      },
      field: 'operation',
      fixed: 'right',
      headerAlign: 'center',
      showOverflow: false,
      title: '操作',
      width: 150,
    },
  ];
}